package FileIO.stream;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

public class useFileInputStreamBatchRead {
    public static void main(String[] args) throws IOException {
        InputStream input = new FileInputStream("src/main/data/hello.txt");
        try {
            byte[] buf = new byte[1024];
            int off = 0;
            int bytesRead = 0;
            while ((bytesRead = input.read(buf, off, 1024 - off)) != -1) {
                off += bytesRead;
            }
            String data = new String(buf, 0, off, "utf-8");
            System.out.println(data);
        } finally {
            input.close();
        }
    }
}
